home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
trap13.arc
/
SSFIX.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-04-09
|
6KB
|
206 lines
name Td
page 63,110
CODE segment
assume CS:CODE
Td proc near
org 100h ; .COM file
start: jmp instal ; to install code
savint: dd ? ; save old int13 addr
doing: db ? ; routine execute status
save: dw 6 dup(?)
saveCS dw ?
saveIP dw ?
ourst: db 24 dup('stack ')
estack: db 0
ostseg: dw ?
ostofs: dw ?
tdsig dw 7777h
dw 8888h
dw 9999h
dw 0aaaah
dw 0deadh
tdres proc near
push ax
push bp ; get caller's address
mov bp,sp
mov ax,word ptr [bp+4]
mov word ptr [saveIP], ax
mov ax, word ptr [bp+6]
mov word ptr [saveCS], ax
pop bp
push ds
pushf
push cs
pop ds
cmp byte ptr [doing],00h ; can we execute?
jz tdgk ; sure!
jmp tdext ; int13 in progress, exit
tdgk: mov byte ptr [doing],0ffh ; in progress marker
mov word ptr [save],ax ; keep caller's stuff
mov word ptr [save+4],cx ;
pushf
pop ax
mov word ptr [save+10],ax
cli
mov ax,ss
mov ostseg,ax
mov ostofs,sp ; save his stack, use ours
mov ax,ds
mov ss,ax
mov sp,offset estack
sti
mov ax,word ptr[save] ; get his stuff again
mov cx,word ptr[save+4]
cmp ch,27h ; test for SS sector read
jnz doint
cmp cl,02h
jz fake
cmp cl,06h
jnz doint
fake: mov ax,1000h ; fake the error that SS likes
mov word ptr[save],ax
mov ax,word ptr [save+10] ; get flags
or ax,1 ; set carry
mov word ptr[save+10],ax
jmp fakex
doint: pushf
call dword ptr [savint] ; simulate an OLD int
mov word ptr [save], ax ; OLD int's result regs
mov word ptr [save+4],cx
fakex: cli ; restore stack
mov ax,ostseg
mov ss,ax
mov sp,ostofs
sti
tdext: popf ; caller's local stuff
pop ds
pop ax
pop ax ; junk caller's ip
pop ax ; junk his CS
pop ax ; finally his flags
pushf ; give him OURS
mov ax, word ptr[saveCS] ; and his CS back
push ax
mov ax, word ptr[saveIP] ; and his IP
push ax
mov ax,word ptr [save+10] ; our flags (to be safe)
push ax
popf
mov ax, word ptr[save] ; result in AX
mov byte ptr [doing],00h ; no more execute
tdend: iret ; adios!
tdall: nop ; "offset + 1" of res
tdres endp
tdlen equ tdend-tdres ; routine length
siglen equ tdres-tdsig ; check length
intoff equ (13h*4)+0 ; addr of tick vector
intseg equ (13h*4)+2 ;
instal: push ds ; save DOS return word
xor ax,ax ; clear out ax
push ax ; for return
push ax ; and to zero ES
pop es
mov ax,es:[intoff] ; get 13h vector offset
push ax ; move into di
pop di ;
sub di,siglen ; point to where sig should be
mov ax,es:[intseg] ; get 13h vector seg
push ax ; move into es
pop es ;
mov si,offset tdsig ; get our routine's address
cld ; forward compare
mov cx,siglen ; length of routine
rescmp: cmps ds:byte ptr[si],es:[di] ; loop while Z
loopz rescmp
jz reserr ; if all equal, already res.
xor ax,ax ; segment 0000
push ax
pop es
mov ax,word ptr es:[intoff] ; get bios vector offset
mov bx,offset savint
mov word ptr [bx],ax ; store 13h routine's offset
mov ax,word ptr es:[intseg] ; get 13h routine's segment
inc bx
inc bx
mov word ptr [bx],ax ; store
mov byte ptr [doing], 0ffh ; fake executing
cli ; no interrupts while
mov word ptr es:[intoff], offset tdres ; storing
mov word ptr es:[intseg], cs ; vectors
sti ; interrupts Again
mov dx,offset resmsg ; good msg
mov ah,9 ; output string
int 21h ; display
mov doing, 00h ; allow executing
mov dx,tdall ; our resident portion
int 27h ; terminate & stay resident
reserr: mov dx,offset errmsg ; error msg
mov ah,9 ; output string
int 21h ; display
int 20h ; go home
Td endp
resmsg: db 'SSFIX - Screen Sculptor Protection Fix'
db ' - (c) 1985 Eric Pederson'
db 0dh
db 0ah
db 'Resident portion loaded'
db '$'
errmsg: db 'SSFIX - Already resident'
db '$'
CODE ends
end start